package com.shop.web;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.commons.io.IOUtils;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class UploadManyAction extends ActionSupport {
	private File upload[];
	private String uploadContentType[];
	private String uploadFileName[];
	
	@Override
	public String execute() throws Exception {
		String path=ServletActionContext.getServletContext().getRealPath("uploadFiles");
		for(int i=0; i<uploadFileName.length; i++){
			File uploadFile = new File(path,uploadFileName[i]);
			FileInputStream input = new FileInputStream(upload[i]);
			FileOutputStream output = new FileOutputStream(uploadFile);
			IOUtils.copy(input, output );
		}
		return super.execute();
	}

	public File[] getUpload() {
		return upload;
	}

	public void setUpload(File[] upload) {
		this.upload = upload;
	}

	public String[] getUploadContentType() {
		return uploadContentType;
	}

	public void setUploadContentType(String[] uploadContentType) {
		this.uploadContentType = uploadContentType;
	}

	public String[] getUploadFileName() {
		return uploadFileName;
	}

	public void setUploadFileName(String[] uploadFileName) {
		this.uploadFileName = uploadFileName;
	}
	
}
